#!/usr/bin/env python
# encoding: utf-8
'''
@author: liuchong
@contact: lucas@007vin.com
@software: garner
@file: banzhou.py
@time: 2020/9/9 2:44 下午
@desc:
'''

import pandas as pd
from sqlalchemy import create_engine

db_info = {'user': 'a',
           'password': '110',
           'host': '192.168.10.193',
           'database': 'vwag'  # 这里我们事先指定了数据库，后续操作只需要表即可
           }

start,page=0,0
page_size=100000
engine = create_engine('mysql+pymysql://%(user)s:%(password)s@%(host)s/%(database)s?charset=utf8' % db_info,encoding='utf-8')
for x in range(1,5):
    start = page*page_size
    sql = "select * from cars_part_num_new limit {},{}".format(start, page_size)
    df = pd.read_sql_query(sql, engine)
    file_name = '/Users/carl/Desktop/cars_part_num_new' + str(x) + '.csv'  # 保存文件路径以及文件名称
    df.to_csv(file_name, index=False)
    page += 1


# for i in range(0, 10):
#     save_data = data.iloc[i*1000000 + 1 : (i+1)*1000000+1]
#     file_name = '/Users/carl/Desktop/cars_part_num_new' + str(i) + '.csv'  # 保存文件路径以及文件名称
#     save_data.to_csv(file_name, index=False)